//1、编写 router/index.js文件
import { createMemoryHistory, createRouter } from 'vue-router'

import Login from "@/components/Login.vue";
import Register from "@/components/Register.vue";
import Main from "@/components/Main.vue";

//2、配置路由表信息
const routes = [
    {
        path: '/login',
        name: 'login',
        //1.直接导入方式
        component: Login
    },
    {
        path: '/register',
        name: 'register',
        //1.直接导入方式
        component: Register
    },
    {
        path: '/main',
        name: 'main',
        //1.直接导入方式
        component: Main,
        children: [
            {
                path: 'list',
                name: 'list',
                component: () => import('@/components/main/list.vue')
            },
            {
                path: 'upload/:id',
                name: 'upload',
                component: () => import('@/components/main/upload.vue')
            }
        ]
    },
]

//创建路由器
const router = createRouter({
    history: createMemoryHistory(),
    routes,
})
export { router }